<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div class="modal-dialog ms-modal-dialog" style="width: 950px; margin-top: 50px;">
  <div class="modal-content">

    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
      <h4 class="modal-title">变更公司信息</h4>
    </div>
      
    <form class="form-horizontal ms-form modal-search-form" role="form" method="POST" action="${ctx.host}/suppliers/${supplierId}/change" data-validate="true">
    
      <input type="hidden" name="supplierInfoId" value="${supplierInfo.id}" /> 
      <input type="hidden" name="supplierId" value="${supplier.id}" />
      <input type="hidden" name="versionId" value="${version.id}" />
      
      <div class="modal-body">
           
        <div class="form-horizontal ms-form form-personal-info">
        
          <div class="form-group ms-form-group">
            <label class="control-label col-xs-3 ">1&nbsp;运输公司代码：</label>
            <div class="col-xs-3 pull-left">
              <strong>${supplier.code}</strong>
            </div>
            <label class="control-label col-xs-3 ">2&nbsp;<span class="color-red">*</span>运输公司现用名(全称)：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="name" data-validate="required" class="form-control" value="${supplier.name}" tabindex="1" autocomplete="off"/>
            </div>
          </div> 
  
          <div class="form-group  ms-form-group">
            <label class="control-label col-xs-3">3.1&nbsp;运输公司曾用名(全称)I：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="formerName" class="form-control" value="${supplierInfo.formerName}" tabindex="1" autocomplete="off"/>
            </div>
            <label class="control-label col-xs-3">3.2&nbsp;运输公司曾用名II(全称)：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="secondFormerName" class="form-control" value="${supplierInfo.secondFormerName}" tabindex="1" autocomplete="off"/>
            </div>
          </div> 
  
          <div class="form-group  ms-form-group">
            <label class="control-label col-xs-3">4&nbsp;<span class="color-red">*</span>董事长：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="chairman" data-validate="required" class="form-control" value="${supplierInfo.chairman}" tabindex="1" autocomplete="off"/>
            </div>
          </div>
        
          <div class="form-group  ms-form-group">
            <label class="control-label col-xs-3">5&nbsp;<span class="color-red">*</span>总经理：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="manager" data-validate="required" class="form-control" value="${supplierInfo.manager}" tabindex="1" autocomplete="off"/>
            </div>
          
            <label class="control-label col-xs-3">6&nbsp;<span class="color-red">*</span>总经理联系电话：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="managerPhone" data-validate="required" class="form-control" value="${supplierInfo.managerPhone}" tabindex="1" autocomplete="off" data-validate="required|mobile"/>
            </div>
          </div>
          
          <div class="form-group  ms-form-group">
            <label class="control-label col-xs-3">7.1&nbsp;<span class="color-red">*</span>总经理Email&nbsp;I：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="managerEmail" data-validate="required" class="form-control" value="${supplierInfo.managerEmail}" tabindex="1" autocomplete="off"/>
            </div>
            
            <label class="control-label col-xs-3">7.2&nbsp;<span class="color-red">*</span>总经理Email&nbsp;II：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="secondManagerEmail" class="form-control" value="${supplierInfo.secondManagerEmail}" tabindex="1" autocomplete="off"/>
            </div>
          </div>
  
           <div class="form-group  ms-form-group">
             <label class="control-label col-xs-3">8&nbsp;<span class="color-red">*</span>注册资金(万元)：</label>
             <div class="col-xs-3 pull-left">
               <input type="text" name="registerCapital" class="form-control" value="${supplierInfo.registerCapital}" tabindex="1" autocomplete="off"/>
             </div>
             
             <label class="control-label col-xs-3">9&nbsp;<span class="color-red">*</span>成立年月：</label>
             <div class="col-xs-3 pull-left">
               <input type="text" name="yearFounded" data-validate="required" class="form-control year-month" value="<fmt:formatDate value="${supplierInfo.yearFounded}" pattern="yyyy-MM"/>" tabindex="1" autocomplete="off"/>
             </div>
           </div>
  
           <div class="form-group  ms-form-group">
             <label class="control-label col-xs-3">10&nbsp;<span class="color-red">*</span>注册地：</label>
             <div class="col-xs-3 pull-left">
               <input type="text" name="registerAddress" class="form-control" value="${supplierInfo.registerAddress}" tabindex="1" autocomplete="off"/>
             </div>
             
             <label class="control-label col-xs-3">11&nbsp;<span class="color-red">*</span>联系地址：</label>
             <div class="col-xs-3 pull-left">
               <input type="text" name="contactAddress" data-validate="required" class="form-control" value="${supplierInfo.contactAddress}" tabindex="1" autocomplete="off"/>
             </div>
           </div>
           
          <div class="form-group  ms-form-group">
            <label class="control-label col-xs-3">13.1&nbsp;<span class="color-red">*</span>体系标准文件类型：</label>
            <div class="col-xs-9 pull-left">
              <select name="standardDocument" data-validate="required" multiple class="select2 multiple form-control">
                <option></option>
                <c:forEach var="standardDocument" items="${enums['StandardDocument']}">
                  <option value="${standardDocument.code}" ${supplierInfo.standardDocument.contains(standardDocument.code) ? 'selected' : ''}>${standardDocument.description}</option>
                </c:forEach>
              </select>
            </div>
          </div>
          
<%--           <div class="form-group  ms-form-group">
            <label class="control-label col-xs-3">13.2&nbsp;<span class="color-red standard-document-date">*</span>体系文件有效期：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="standardDocumentDate" class="form-control date" value='<fmt:formatDate value="${supplierInfo.standardDocumentDate}" pattern="yyyy-MM-dd"/>' autocomplete="off"/>
            </div>
          </div> --%>
      
          <div class="form-group  ms-form-group">
            <label class="control-label col-xs-3">14.1&nbsp;<span class="color-red">*</span>营业执照原件扫描件上传：</label>
            <div class="col-xs-3 pull-left upload-cover">
	            <div class="input-group">
	              <iframe src="${config.uploadHost}?fileObject=SupplierModifiedVersion&objectId=${version.id}&fileName=businessLicense" style="width: 100%; height: 35px; border: none;"></iframe>
	            </div>
	          </div>
	          
	          <label class="control-label col-xs-3">14.2&nbsp;<span class="color-red">*</span>营业执照原件扫描件有效期：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="businessLicenseDate" data-validate="required" class="form-control date" value="<fmt:formatDate value="${supplierInfo.businessLicenseDate}" pattern="yyyy-MM-dd"/>" autocomplete="off"/>
            </div>
          </div>
           
          <div class="form-group  ms-form-group">
            <label class="control-label col-xs-3">15.1&nbsp;质量体系认证证书原件扫描件上传：</label>
            <div class="col-xs-3 pull-left upload-cover">
              <div class="input-group">
                <iframe src="${config.uploadHost}?fileObject=SupplierModifiedVersion&objectId=${version.id}&fileName=qualitySystem" style="width: 100%; height: 35px; border: none;"></iframe>
              </div>
            </div>
            
            <label class="control-label col-xs-3">15.2&nbsp;<span class="color-red standard-document-date">*</span>&nbsp;质量体系认证证书原件扫描件有效期：</label>
            <div class="col-xs-3 pull-left">
              <input data-validate="required" type="text" name="standardDocumentDate" class="form-control date" value="<fmt:formatDate value="${supplierInfo.standardDocumentDate}" pattern="yyyy-MM-dd"/>" autocomplete="off"/>
            </div>
          </div>
           
          <div class="form-group  ms-form-group">
            <label class="control-label col-xs-3">16.1&nbsp;办公及停车场地租房/购房合同扫描件上传：</label>
            <div class="col-xs-3 pull-left upload-cover">
              <div class="input-group">
                <iframe src="${config.uploadHost}?fileObject=SupplierModifiedVersion&objectId=${version.id}&fileName=leaseContract" style="width: 100%; height: 35px; border: none;"></iframe>
              </div>
            </div>
            
<%--             <label class="control-label col-xs-3">16.2&nbsp;质量体系认证证书原件扫描件有效期：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="leaseContractDate" class="form-control date" value="<fmt:formatDate value="${supplierInfo.leaseContractDate}" pattern="yyyy-MM-dd"/>" autocomplete="off"/>
            </div> --%>
          </div> 
          
          <div class="form-group  ms-form-group">
            <label class="control-label col-xs-3">17.1&nbsp;道路运输许可证上传：</label>
            <div class="col-xs-3 pull-left upload-cover">
              <div class="input-group">
                <iframe src="${config.uploadHost}?fileObject=SupplierModifiedVersion&objectId=${version.id}&fileName=transportCert" style="width: 100%; height: 35px; border: none;"></iframe>
              </div>
            </div>
            
            <label class="control-label col-xs-3">17.2&nbsp;道路运输许可证有效期：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="transportCertDate" class="form-control date" value="<fmt:formatDate value="${supplierInfo.transportCertDate}" pattern="yyyy-MM-dd"/>" autocomplete="off"/>
            </div>
          </div> 
          
          <div class="form-group  ms-form-group">
            <label class="control-label col-xs-3">18&nbsp;变更申报表上传：</label>
            <div class="col-xs-3 pull-left upload-cover">
              <div class="input-group">
                <iframe src="${config.uploadHost}?fileObject=SupplierModifiedVersion&objectId=${version.id}&fileName=changeForm" style="width: 100%; height: 35px; border: none;"></iframe>
              </div>
            </div>

            <label class="control-label col-xs-3">19 &nbsp;统一社会信用代码：</label>
            <div class="col-xs-3 pull-left upload-cover">
              <div class="input-group">
                <input type="text" name="uniformSocialCreditCode" class="form-control" value="${supplierInfo.uniformSocialCreditCode}" autocomplete="off"/>
              </div>
            </div>
          </div>
       
        </div>

        <div class="modal-footer ms-modal-footer">
          <button type="submit" class="btn ms-btn btn-primary">确定</button>
          <button type="button" class="btn ms-btn ms-btn-gary" data-dismiss="modal">取消</button>
        </div>
        
      </div>
    </form>
      
  </div>
</div>

<script type="text/javascript">
  $(document).ready(function () {

    $('select[name="companyProperty"]').select2({
      theme: "classic",
      placeholder: '请选择',
      minimumResultsForSearch: -1,
      allowClear: true
    });

    $('select[name="standardDocument"]').select2({
      theme: "classic",
      placeholder: '请选择',
      minimumResultsForSearch: -1,
      allowClear: true
    });
    
    $('.date').datetimepicker({
      format: 'yyyy-mm-dd',
      autoclose: true,
      language: 'zh-CN',
      todayBtn: 'linked',
      startDate: '${today}',
      todayHighlight: true,
      pickerPosition: 'bottom-right',
      minView: 'month'
    });

    $('.year-month').datetimepicker({
      format: 'yyyy-mm',
      autoclose: true,
      language: 'zh-CN',
      todayBtn: true,
      startView: 'year',
      minView:'year',
      maxView:'decade',
    });
    
    $(document).on('change', 'select[name="standardDocument"]', function(e) {
      var standardDocument = $('select[name="standardDocument"]').val();
      if (standardDocument != '01') {
        $('span.standard-document-date').show();
        $('input[name="standardDocumentDate"]').attr('data-validate', 'required');
      } else {
        $('span.standard-document-date').hide();
        $('input[name="standardDocumentDate"]').removeAttr('data-validate');
      }
    });

  })
</script>